﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.IO;
using System.Xml.Serialization;
using System.Xml;

namespace IWS.SiteManager.Core
{
	internal class Utility
	{
		/// <summary>
		/// Serializes and object to a stream. It will flush and close the underlying stream. 
		/// </summary>
		/// <param name="output"></param>
		/// <param name="data"></param>
		public static void SerializeXml(Stream output, object data)
		{
			XmlSerializer xs = new XmlSerializer(data.GetType());
			XmlWriterSettings settings = new XmlWriterSettings();
			settings.Encoding = Encoding.UTF8;
			XmlWriter writer = XmlTextWriter.Create(output, settings);
			xs.Serialize(writer, data);
			writer.Flush();
			writer.Close();
		}
	}
}
